package com.htc.callcare.activities;

import com.htc.callcare.R;
import com.htc.callcare.infrastructure.globalVar;
import com.htc.callcare.viewcontroller.Popup_Call;

import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class SettingActivity extends Activity {
	RadioGroup group;
	public static RadioButton amr;
	public static RadioButton mp4;
	public static RadioButton gpp;
	public static SettingActivity instance;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setting_screen);
		initView();
		listener();
	}
	
	public static SettingActivity getInstance(){
		if(instance==null){
			return new SettingActivity();
		}
		else{
			return instance;
		}
	}

	private void initView() {
		group = (RadioGroup) findViewById(R.id.groupOutputFile);
		amr = (RadioButton) group.findViewById(R.id.radioAMR);
		mp4 = (RadioButton) group.findViewById(R.id.radioWMV);
		gpp = (RadioButton) group.findViewById(R.id.radio3GPP);
	}

	private void listener() {
		group.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				switch (checkedId) {
				case R.id.radioAMR:
					Toast.makeText(getApplicationContext(), "AMR",
							Toast.LENGTH_SHORT).show();
					Popup_Call.instance.setOutputFormat(globalVar.AMR);
					break;

				case R.id.radioWMV:
					Toast.makeText(getApplicationContext(), "MP4",
							Toast.LENGTH_SHORT).show();
					Popup_Call.instance.setOutputFormat(globalVar.MP4);
					break;
				case R.id.radio3GPP:
					Toast.makeText(getApplicationContext(), "3GPP",
							Toast.LENGTH_SHORT).show();
					Popup_Call.instance.setOutputFormat(globalVar.THREE_GPP);
					break;
				}
			}
		});
	}

}
